Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

deSound.hpp

Go to the documentation of this file.
00001 ///////////////////////////////////////////////////////////////////////////////
00002 /// @file deSound.hpp
00003 ///
00004 /// @brief Destiny Sound System Data Structures and Classes
00005 ///
00006 /// @author paradoxnj
00007 ///
00008 /// This file is the intellectual property of Novus Delta, LLC.. Usage of the
00009 /// contents of this file is subject to the Destiny3D Member License which
00010 /// can be found at http://www.destiny3d.com.  Any other usage is prohibited.
00011 ///
00012 /// This file is distributed "AS IS" without warranty of any kind.  Novus
00013 /// Delta, LLC. does not guarantee the fitness of the contents of this file
00014 /// for any particular purpose.
00015 ///
00016 /// Copyright (C) 2001-2003 Novus Delta, LLC. All Rights Reserved.
00017 ///
00018 /// <hr>
00019 ///                                 Change History
00020 /// <hr>
00021 ///
00022 /// @date Jan 2002
00023 /// @author paradoxnj
00024 /// @remarks Creation
00025 ///
00026 ///////////////////////////////////////////////////////////////////////////////
00027 
00028 #ifndef DESOUND_H
00029 #define DESOUND_H
00030 
00031 //Destiny Includes
00032 //#include "deFileSystem.hpp"
00033 #include "deResource.hpp"
00034 //#include "deMath.hpp"
00035 
00036 //DLL Interface
00037 #if defined(DESOUND_DLL_EXPORTS) || defined(DESTINY3D_EXPORT_ALL)
00038 #   define DESOUND_API              extern "C" DEDLL_EXPORT
00039 #elif defined(DESTINY3D_STATIC_LINK)
00040 #   define DESOUND_API              extern "C"
00041 #else
00042 #   define DESOUND_API              extern "C" DEDLL_IMPORT
00043 #endif
00044 
00045 #ifdef USING_DESTINY3D
00046 #ifdef _DEBUG
00047 #   ifdef DESTINY3D_STATIC_LINK
00048 #       pragma comment(lib, "deSound_sd")
00049 #   else
00050 #       pragma comment(lib, "deSoundd")
00051 #   endif //DESTINY3D_STATIC_LINK
00052 #else
00053 #   ifdef DESTINY3D_STATIC_LINK
00054 #       pragma comment(lib, "deSound_s")
00055 #   else
00056 #       pragma comment(lib, "deSound")
00057 #   endif //DESTINY3D_STATIC_LINK
00058 #endif //_DEBUG
00059 #endif //USING_DESTINY3D
00060 
00061 class IdeSoundSystem;
00062 
00063 //The sound factory functions
00064 DESOUND_API IdeSoundSystem *IdeSoundSystem_CreateDirectSound(HWND hWnd);
00065 DESOUND_API IdeSoundSystem *IdeSoundSystem_CreateEAX(HWND hWnd);
00066 DESOUND_API int IdeSoundData_GetInterfaceID();
00067 
00068 //System Includes
00069 typedef struct tWAVEFORMATEX WAVEFORMATEX;
00070 
00071 //Some temporary typedefs
00072 typedef unsigned char                           uint8;
00073 
00074 //Typedefs to lessen typing
00075 typedef unsigned int                            u_int;
00076 typedef unsigned short                          u_short;
00077 typedef unsigned long                           u_long;
00078 
00079 //Constants
00080 #define MAX_STRING                              255
00081 #define MAX_BUFFERS                             20
00082 
00083 //Sound FX Types
00084 typedef enum deSFX_Type
00085 {
00086     DESFX_TYPE_CHORUS = 0,
00087     DESFX_TYPE_GARGLE,
00088     DESFX_TYPE_ECHO,
00089     DESFX_TYPE_DISTORTION,
00090     DESFX_TYPE_COMPRESSOR,
00091     DESFX_TYPE_FLANGER,
00092     DESFX_TYPE_PARAMEQ,
00093     DESFX_TYPE_REVERB,
00094 
00095     DESFX_ENUM
00096 } deSFX_Type;
00097 
00098 //Sound FX Ranges
00099 #define DESFX_GARGLE_RATEHZ_MIN                         1
00100 #define DESFX_GARGLE_RATEHZ_MAX                         1000
00101 
00102 #define DESFX_CHORUS_WAVE_TRIANGLE                      0
00103 #define DESFX_CHORUS_WAVE_SIN                           1
00104 
00105 #define DESFX_CHORUS_WETDRYMIX_MIN                      0.0f
00106 #define DESFX_CHORUS_WETDRYMIX_MAX                      100.0f
00107 #define DESFX_CHORUS_DEPTH_MIN                          0.0f
00108 #define DESFX_CHORUS_DEPTH_MAX                          100.0f
00109 #define DESFX_CHORUS_FEEDBACK_MIN                       -99.0f
00110 #define DESFX_CHORUS_FEEDBACK_MAX                       99.0f
00111 #define DESFX_CHORUS_FREQUENCY_MIN                      0.0f
00112 #define DESFX_CHORUS_FREQUENCY_MAX                      10.0f
00113 #define DESFX_CHORUS_DELAY_MIN                          0.0f
00114 #define DESFX_CHORUS_DELAY_MAX                          20.0f
00115 #define DESFX_CHORUS_PHASE_MIN                          0
00116 #define DESFX_CHORUS_PHASE_MAX                          4
00117 
00118 #define DESFX_CHORUS_PHASE_NEG_180                      0
00119 #define DESFX_CHORUS_PHASE_NEG_90                       1
00120 #define DESFX_CHORUS_PHASE_ZERO                         2
00121 #define DESFX_CHORUS_PHASE_90                           3
00122 #define DESFX_CHORUS_PHASE_180                          4
00123 
00124 #define DESFX_FLANGER_WAVE_TRIANGLE                     0
00125 #define DESFX_FLANGER_WAVE_SIN                          1
00126 
00127 #define DESFX_FLANGER_WETDRYMIX_MIN                     0.0f
00128 #define DESFX_FLANGER_WETDRYMIX_MAX                     100.0f
00129 #define DESFX_FLANGER_FREQUENCY_MIN                     0.0f
00130 #define DESFX_FLANGER_FREQUENCY_MAX                     10.0f
00131 #define DESFX_FLANGER_DEPTH_MIN                         0.0f
00132 #define DESFX_FLANGER_DEPTH_MAX                         100.0f
00133 #define DESFX_FLANGER_PHASE_MIN                         0
00134 #define DESFX_FLANGER_PHASE_MAX                         4
00135 #define DESFX_FLANGER_FEEDBACK_MIN                      -99.0f
00136 #define DESFX_FLANGER_FEEDBACK_MAX                      99.0f
00137 #define DESFX_FLANGER_DELAY_MIN                         0.0f
00138 #define DESFX_FLANGER_DELAY_MAX                         4.0f
00139 
00140 #define DESFX_FLANGER_PHASE_NEG_180                     0
00141 #define DESFX_FLANGER_PHASE_NEG_90                      1
00142 #define DESFX_FLANGER_PHASE_ZERO                        2
00143 #define DESFX_FLANGER_PHASE_90                          3
00144 #define DESFX_FLANGER_PHASE_180                         4
00145 
00146 #define DESFX_ECHO_WETDRYMIX_MIN                        0.0f
00147 #define DESFX_ECHO_WETDRYMIX_MAX                        100.0f
00148 #define DESFX_ECHO_FEEDBACK_MIN                         0.0f
00149 #define DESFX_ECHO_FEEDBACK_MAX                         100.0f
00150 #define DESFX_ECHO_LEFTDELAY_MIN                        1.0f
00151 #define DESFX_ECHO_LEFTDELAY_MAX                        2000.0f
00152 #define DESFX_ECHO_RIGHTDELAY_MIN                       1.0f
00153 #define DESFX_ECHO_RIGHTDELAY_MAX                       2000.0f
00154 #define DESFX_ECHO_PANDELAY_MIN                         0
00155 #define DESFX_ECHO_PANDELAY_MAX                         1
00156 
00157 #define DESFX_DISTORTION_GAIN_MIN                       -60.0f
00158 #define DESFX_DISTORTION_GAIN_MAX                       0.0f
00159 #define DESFX_DISTORTION_EDGE_MIN                       0.0f
00160 #define DESFX_DISTORTION_EDGE_MAX                       100.0f
00161 #define DESFX_DISTORTION_POSTEQCENTERFREQUENCY_MIN      100.0f
00162 #define DESFX_DISTORTION_POSTEQCENTERFREQUENCY_MAX      8000.0f
00163 #define DESFX_DISTORTION_POSTEQBANDWIDTH_MIN            100.0f
00164 #define DESFX_DISTORTION_POSTEQBANDWIDTH_MAX            8000.0f
00165 #define DESFX_DISTORTION_PRELOWPASSCUTOFF_MIN           100.0f
00166 #define DESFX_DISTORTION_PRELOWPASSCUTOFF_MAX           8000.0f
00167 
00168 #define DESFX_COMPRESSOR_GAIN_MIN                       -60.0f
00169 #define DESFX_COMPRESSOR_GAIN_MAX                       60.0f
00170 #define DESFX_COMPRESSOR_ATTACK_MIN                     0.01f
00171 #define DESFX_COMPRESSOR_ATTACK_MAX                     500.0f
00172 #define DESFX_COMPRESSOR_RELEASE_MIN                    50.0f
00173 #define DESFX_COMPRESSOR_RELEASE_MAX                    3000.0f
00174 #define DESFX_COMPRESSOR_THRESHOLD_MIN                  -60.0f
00175 #define DESFX_COMPRESSOR_THRESHOLD_MAX                  0.0f
00176 #define DESFX_COMPRESSOR_RATIO_MIN                      1.0f
00177 #define DESFX_COMPRESSOR_RATIO_MAX                      100.0f
00178 #define DESFX_COMPRESSOR_PREDELAY_MIN                   0.0f
00179 #define DESFX_COMPRESSOR_PREDELAY_MAX                   4.0f
00180 
00181 #define DESFX_PARAMEQ_CENTER_MIN                        80.0f
00182 #define DESFX_PARAMEQ_CENTER_MAX                        16000.0f
00183 #define DESFX_PARAMEQ_BANDWIDTH_MIN                     1.0f
00184 #define DESFX_PARAMEQ_BANDWIDTH_MAX                     36.0f
00185 #define DESFX_PARAMEQ_GAIN_MIN                          -15.0f
00186 #define DESFX_PARAMEQ_GAIN_MAX                          15.0f
00187 
00188 #define DESFX_REVERB_INGAIN_MIN                         -96.0f
00189 #define DESFX_REVERB_INGAIN_MAX                         0.0f
00190 #define DESFX_REVERB_INGAIN_DEFAULT                     0.0f
00191 #define DESFX_REVERB_REVERBMIX_MIN                      -96.0f
00192 #define DESFX_REVERB_REVERBMIX_MAX                      0.0f
00193 #define DESFX_REVERB_REVERBMIX_DEFAULT                  0.0f
00194 #define DESFX_REVERB_REVERBTIME_MIN                     0.001f
00195 #define DESFX_REVERB_REVERBTIME_MAX                     3000.0f
00196 #define DESFX_REVERB_REVERBTIME_DEFAULT                 1000.0f
00197 #define DESFX_REVERB_HIGHFREQRTRATIO_MIN                0.001f
00198 #define DESFX_REVERB_HIGHFREQRTRATIO_MAX                0.999f
00199 #define DESFX_REVERB_HIGHFREQRTRATIO_DEFAULT            0.001f
00200 
00201 //Forward class declarations
00202 class deSoundData;
00203 class IdeSoundSystem;
00204 class IdeSoundBuffer;
00205 class deSFXManager;
00206 
00207 //Forward struct declarations
00208 typedef struct deSoundCfg                       deSoundCfg;
00209 typedef struct deSFX_Chorus                     deSFX_Chorus;
00210 typedef struct deSFX_Gargle                     deSFX_Gargle;
00211 typedef struct deSFX_Echo                       deSFX_Echo;
00212 typedef struct deSFX_Distortion                 deSFX_Distortion;
00213 typedef struct deSFX_Compressor                 deSFX_Compressor;
00214 typedef struct deSFX_Reverb                     deSFX_Reverb;
00215 typedef struct deSFX_ParamEQ                    deSFX_ParamEQ;
00216 
00217 //Gargle FX Settings
00218 typedef struct deSFX_Gargle
00219 {
00220     DWORD               m_RateHz;
00221     DWORD               m_WaveShape;
00222 } deSFX_Gargle;
00223 
00224 //Chorus FX Settings
00225 typedef struct deSFX_Chorus
00226 {
00227     float               m_WetDryMix;
00228     float               m_Depth;
00229     float               m_Feedback;
00230     float               m_Frequency;
00231     long                m_WaveForm;
00232     float               m_Delay;
00233     long                m_Phase;
00234 } deSFX_Chorus;
00235 
00236 //Flanger FX Settings
00237 typedef struct deSFX_Flanger
00238 {
00239     float               m_WetDryMix;
00240     float               m_Depth;
00241     float               m_FeedBack;
00242     float               m_Frequency;
00243     long                m_WaveForm;
00244     float               m_Delay;
00245     long                m_Phase;
00246 } deSFX_Flanger;
00247 
00248 //Echo FX Settings
00249 typedef struct deSFX_Echo
00250 {
00251     float               m_WetDryMix;
00252     float               m_Feedback;
00253     float               m_LeftDelay;
00254     float               m_RightDelay;
00255     long                m_PanDelay;
00256 } deSFX_Echo;
00257 
00258 //Distortion FX Settings
00259 typedef struct deSFX_Distortion
00260 {
00261     float               m_Gain;
00262     float               m_Edge;
00263     float               m_PostEQCenterFrequency;
00264     float               m_PostEQBandwidth;
00265     float               m_PreLowPassCutoff;
00266 } deSFX_Distortion;
00267 
00268 //Compressor FX Settings
00269 typedef struct deSFX_Compressor
00270 {
00271     float               m_Gain;
00272     float               m_Attack;
00273     float               m_Release;
00274     float               m_Threshold;
00275     float               m_Ratio;
00276     float               m_Predelay;
00277 } deSFX_Compressor;
00278 
00279 //Parametric EQ FX Settings
00280 typedef struct deSFX_ParamEQ
00281 {
00282     float               m_Center;
00283     float               m_Bandwidth;
00284     float               m_Gain;
00285 } deSFX_ParamEQ;
00286 
00287 //Reverb FX Settings
00288 typedef struct deSFX_Reverb
00289 {
00290     float               m_InGain;
00291     float               m_ReverbMix;
00292     float               m_ReverbTime;
00293     float               m_HighFreqRTRatio;
00294 } deSFX_Reverb;
00295 
00296 //The PCM Data Interface
00297 //class IdeSoundData : virtual public IdeResourceBase
00298 DE3D_INTERFACE(IdeSoundData, IdeResourceBase)
00299 {
00300 protected:
00301     virtual ~IdeSoundData()     {}
00302 
00303 public:
00304     enum interface_t
00305     {
00306         iface_IdeSoundData,
00307         iface_WAV,
00308         iface_OGG,
00309         iface_32Bit=0x7fffffff
00310     };
00311 
00312     virtual deBoolean           Initialize(const char *filename) = 0;
00313     virtual void                Destroy() = 0;
00314 
00315     virtual deBoolean           AtEndOfStream() = 0;
00316     virtual void                SetPosition(long NewPos) = 0;
00317 
00318     virtual int                 GetDataChunk(void *ptr, long size, s32 DataOffset = -1) = 0;
00319     virtual uint8               *GetAllData() = 0;
00320 
00321     virtual int                 GetType() = 0;
00322 
00323     virtual void                GetFormat(WAVEFORMATEX *format) = 0;
00324     virtual u32                 GetLength() = 0;
00325 };
00326 
00327 //The sound system interface
00328 //class IdeSoundSystem : virtual public IdeRefCountBase
00329 DE3D_INTERFACE(IdeSoundSystem, IdeRefCountBase)
00330 {
00331 protected:
00332     virtual ~IdeSoundSystem()   {}
00333 
00334 public:
00335     enum interface_t
00336     {
00337         iface_IdeSoundSystem,
00338         iface_DirectSound,
00339         iface_EAX,
00340         iface_32Bit=0x7fffffff
00341     };
00342 
00343     virtual void                *GetInterface(int interface_id) = 0;
00344 
00345     virtual deBoolean           Initialize(HWND hWnd) = 0;
00346     virtual void                Destroy() = 0;
00347 
00348     virtual IdeSoundBuffer      *CreateSoundBuffer(IdeSoundData *sndData) = 0;
00349 
00350     virtual float               GetRollOffFactor() = 0;
00351     virtual float               GetDopplerFactor() = 0;
00352     virtual float               GetDistanceFactor() = 0;
00353 
00354     virtual void                SetRollOffFactor(float factor) = 0;
00355     virtual void                SetDopplerFactor(float factor) = 0;
00356     virtual void                SetDistanceFactor(float factor) = 0;
00357 
00358     virtual deBoolean           GetListenerPosition(float *x, float *y, float *z) = 0;
00359     virtual deBoolean           GetListenerPosition(deVec3d *pos) = 0;
00360 
00361     virtual deBoolean           GetListenerVelocity(float *x, float *y, float *z) = 0;
00362     virtual deBoolean           GetListenerVelocity(deVec3d *vel) = 0;
00363 
00364     virtual deBoolean           GetListenerOrientation(float *Fx, float *Fy, float *Fz, float *Tx, float *Ty, float *Tz) = 0;
00365     virtual deBoolean           GetListenerOrientation(deVec3d *Front, deVec3d *Top) = 0;
00366 
00367     virtual void                SetListenerPosition(float x, float y, float z) = 0;
00368     virtual void                SetListenerPosition(deVec3d pos) = 0;
00369 
00370     virtual void                SetListenerVelocity(float x, float y, float z) = 0;
00371     virtual void                SetListenerVelocity(deVec3d vel) = 0;
00372     
00373     virtual void                SetListenerOrientation(float Fx, float Fy, float Fz, float Tx, float Ty, float Tz) = 0;
00374     virtual void                SetListenerOrientation(deVec3d Front, deVec3d Top) = 0;
00375 };
00376 
00377 //Sound Configuration Struct
00378 typedef struct deSoundCfg
00379 {
00380     long                        Volume;
00381     long                        Pan;
00382     long                        Freq;
00383 
00384     int                         Repeats;
00385 
00386     deVec3d                     Position;
00387     deVec3d                     Velocity;
00388     
00389     deVec3d                     Cone_Orientation;
00390 
00391     float                       Dist_Min;
00392     float                       Dist_Max;
00393 
00394     float                       ConeAngle_Inner;
00395     float                       ConeAngle_Outer;
00396 
00397     float                       ConeVolume_Outside;
00398 } deSoundCfg;
00399 
00400 //The sound object class
00401 //class IdeSoundBuffer : virtual public IdeRefCountBase
00402 DE3D_INTERFACE(IdeSoundBuffer, IdeRefCountBase)
00403 {
00404 protected:
00405     virtual ~IdeSoundBuffer()   {}
00406 
00407 public:
00408     enum interface_t
00409     {
00410         iface_IdeSoundBuffer,
00411         iface_DirectSound,
00412         iface_EAX,
00413         iface_32Bit=0x7fffffff
00414     };
00415 
00416     virtual void                *GetInterface(int interface_id) = 0;
00417 
00418     virtual deBoolean           Initialize(IdeSoundSystem *ss, IdeSoundData *data) = 0;
00419     virtual deBoolean           Destroy() = 0;
00420 
00421     virtual deBoolean           ApplySettings() = 0;
00422 
00423     virtual void                GetConfig(deSoundCfg &Cfg) = 0;
00424     virtual void                SetConfig(deSoundCfg Cfg) = 0;
00425 
00426     virtual deBoolean           SetVolume(long vol) = 0;
00427     virtual deBoolean           SetPan(long pan) = 0;
00428     virtual deBoolean           SetFrequency(long freq) = 0;
00429 
00430     virtual long                GetVolume() = 0;
00431     virtual long                GetPan() = 0;
00432     virtual long                GetFrequency() = 0;
00433 
00434     virtual deBoolean           Play(deBoolean loop = deFALSE) = 0;
00435     virtual deBoolean           Update() = 0;
00436 
00437     virtual deBoolean           Stop(deBoolean rewind = deTRUE) = 0;
00438     virtual deBoolean           IsPlaying() = 0;
00439 };
00440 
00441 #endif

Generated on Mon Sep 12 19:58:39 2005 for Destiny3D by doxygen1.3-rc3